﻿define([
    'Wjs/ui/elements/notifiers/Notifier'
],
function () {
    'use strict';

    var Notifier = Wjs.getType('Notifier');

    return Wjs.defineOnce({

        type: 'mouseupNotifier',

        'static': true,

        base: Notifier,

        // For static types this is fired when the instance is created
        onTypeDefined: function (mouseupNotifier) {

            window.addEventListener('mouseup', function (evt) {
                mouseupNotifier.onMouseup(evt);
            });

        },

        // Notifies the subscribers about the mouse up event
        onMouseup: function (evt) {

            this.views.forEach(function (view) {

                if (view.onExternalMouseup) {
                    view.onExternalMouseup(evt);
                }
            });
        }
    });

});